import 'package:flutter/material.dart';
import 'package:test2/base/base_page.dart';
import 'package:test2/util/platform.dart';
import 'package:test2/view/hotkey.dart';
import 'package:test2/view/tag.dart';

class SettingsPage extends StatefulWidget {
  const SettingsPage({super.key});

  @override
  State<SettingsPage> createState() => _SettingsPageState();
}

class _SettingsPageState extends BaseState<SettingsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("设置")),
      body: SizedBox.expand(
        child: Container(
          child: Column(
            children: [
              if (PlatformUtil.isDesktop()) getMenu("快捷键", hotKeySetting),
              getMenu("标签管理", tagSetting),
            ],
          ),
        ),
      ),
    );
  }

  Widget getMenu(String title, GestureTapCallback? onTap) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: onTap,
      child: Container(
        padding: EdgeInsets.all(16),
        width: double.maxFinite,
        // color: Colors.red,
        child: Row(
          children: [
            Text(title),
            Spacer(),
            Icon(Icons.arrow_forward_ios, size: 16),
          ],
        ),
      ),
    );
  }

  void hotKeySetting() {
    startPage(HotkeySetting());
  }

  void tagSetting() {
    startPage(TagSetting());
  }
}
